package com.web.dao;

import com.web.entity.InviteInfo;
import com.web.entity.UserInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserInfoMapper {
    @Delete({
        "delete from APP_USER_INFO",
        "where user_id = #{userId,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String userId);

    @Insert({
        "insert into APP_USER_INFO (user_id, wx_id, ",
        "qq_id, invite_code, ",
        "jg_id, phone, password, ",
        "sex, date_of_birth, ",
        "email, avatar, nickname, ",
        "credit_score, balance, ",
        "currency, address, ",
        "qq_number, profession, ",
        "interest, is_auth, ",
        "is_expert, is_designer, ",
        "is_vip, is_supply, ",
        "ip_address, create_time, ",
        "modify_time, longitude, ",
        "latitude, create_by, ",
        "modify_by)",
        "values (#{userId,jdbcType=VARCHAR}, #{wxId,jdbcType=VARCHAR}, ",
        "#{qqId,jdbcType=VARCHAR}, #{inviteCode,jdbcType=VARCHAR}, ",
        "#{jgId,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, ",
        "#{sex,jdbcType=INTEGER}, #{dateOfBirth,jdbcType=TIMESTAMP}, ",
        "#{email,jdbcType=VARCHAR}, #{avatar,jdbcType=VARCHAR}, #{nickname,jdbcType=VARCHAR}, ",
        "#{creditScore,jdbcType=INTEGER}, #{balance,jdbcType=DOUBLE}, ",
        "#{currency,jdbcType=INTEGER}, #{address,jdbcType=VARCHAR}, ",
        "#{qqNumber,jdbcType=VARCHAR}, #{profession,jdbcType=VARCHAR}, ",
        "#{interest,jdbcType=VARCHAR}, #{isAuth,jdbcType=INTEGER}, ",
        "#{isExpert,jdbcType=INTEGER}, #{isDesigner,jdbcType=INTEGER}, ",
        "#{isVip,jdbcType=INTEGER}, #{isSupply,jdbcType=VARCHAR}, ",
        "#{ipAddress,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{modifyTime,jdbcType=TIMESTAMP}, #{longitude,jdbcType=VARCHAR}, ",
        "#{latitude,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, ",
        "#{modifyBy,jdbcType=VARCHAR})"
    })
    int insert(UserInfo record);

    int insertSelective(UserInfo record);

    @Select({
        "select",
        "user_id, wx_id, qq_id, invite_code, jg_id, phone, password, sex, date_of_birth, ",
        "email, avatar, nickname, credit_score, balance, currency, address, qq_number, ",
        "profession, interest, is_auth, is_expert, is_designer, is_vip, is_supply, ip_address, ",
        "create_time, modify_time, longitude, latitude, create_by, modify_by",
        "from APP_USER_INFO",
        "where user_id = #{userId,jdbcType=VARCHAR}"
    })
    @ResultMap("BaseResultMap")
    UserInfo selectByPrimaryKey(String userId);

    int updateByPrimaryKeySelective(UserInfo record);

    @Update({
        "update APP_USER_INFO",
        "set wx_id = #{wxId,jdbcType=VARCHAR},",
          "qq_id = #{qqId,jdbcType=VARCHAR},",
          "invite_code = #{inviteCode,jdbcType=VARCHAR},",
          "jg_id = #{jgId,jdbcType=VARCHAR},",
          "phone = #{phone,jdbcType=VARCHAR},",
          "password = #{password,jdbcType=VARCHAR},",
          "sex = #{sex,jdbcType=INTEGER},",
          "date_of_birth = #{dateOfBirth,jdbcType=TIMESTAMP},",
          "email = #{email,jdbcType=VARCHAR},",
          "avatar = #{avatar,jdbcType=VARCHAR},",
          "nickname = #{nickname,jdbcType=VARCHAR},",
          "credit_score = #{creditScore,jdbcType=INTEGER},",
          "balance = #{balance,jdbcType=DOUBLE},",
          "currency = #{currency,jdbcType=INTEGER},",
          "address = #{address,jdbcType=VARCHAR},",
          "qq_number = #{qqNumber,jdbcType=VARCHAR},",
          "profession = #{profession,jdbcType=VARCHAR},",
          "interest = #{interest,jdbcType=VARCHAR},",
          "is_auth = #{isAuth,jdbcType=INTEGER},",
          "is_expert = #{isExpert,jdbcType=INTEGER},",
          "is_designer = #{isDesigner,jdbcType=INTEGER},",
          "is_vip = #{isVip,jdbcType=INTEGER},",
          "is_supply = #{isSupply,jdbcType=VARCHAR},",
          "ip_address = #{ipAddress,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "modify_time = #{modifyTime,jdbcType=TIMESTAMP},",
          "longitude = #{longitude,jdbcType=VARCHAR},",
          "latitude = #{latitude,jdbcType=VARCHAR},",
          "create_by = #{createBy,jdbcType=VARCHAR},",
          "modify_by = #{modifyBy,jdbcType=VARCHAR}",
        "where user_id = #{userId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(UserInfo record);


    UserInfo findById(@Param("key") String key, @Param("value") String value);

    List<InviteInfo> myInviteInfo(@Param("inviteCode") String inviteCode);

    List<UserInfo> peopleNearby(@Param("longitude1") String longitude1,@Param("longitude2") String longitude2
            ,@Param("latitude1") String latitude1,@Param("latitude2") String latitude2);
}